package com.ywy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ywy.entity.UserMessage;
import com.ywy.mapper.UserMessageMapper;
import com.ywy.service.UserMessageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ywy.vo.UserMessageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户消息 服务实现类
 * </p>
 *
 * @author ywy
 * @since 2021-12-24
 */
@Service
public class UserMessageServiceImpl extends ServiceImpl<UserMessageMapper, UserMessage> implements UserMessageService {
    @Autowired
    private UserMessageMapper userMessageMapper;

    @Override
    public IPage<UserMessageVo> listByPage(Page page, QueryWrapper<UserMessage> queryWrapper) {
        return userMessageMapper.listByPage(page, queryWrapper);
    }

    @Override
    public void updateToRead(List<Integer> ids) {
        if(ids.isEmpty()) {
            return;
        }
        userMessageMapper.updateToRead(new QueryWrapper<UserMessage>().in("id", ids));
    }
}
